import { useHistory } from 'react-router-dom';

export const App3 = () => {
  const history = useHistory<{ from: string }>();

  const handleClick = () => {
    // 跳转到App4,不带数据
    // history.push('/app4');
    // 带数据第1种写法
    history.push('/app4?from=/app3&key2=value2', {
      from: '/app3',
    });
    // 带数据第2种写法
    // history.push({
    //   pathname: '/app4',
    //   state: {
    //     from: '/app3',
    //   },
    // });
  };
  return (
    <div>
      App3
      <button onClick={handleClick}>跳转到App4</button>
    </div>
  );
};
